//
//  HostDetailViewController.m
//  penzer
//
//  Created by caiyc on 2018/10/1.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "HostDetailViewController.h"
#import "SGPagingView.h"
#import "CollectListViewController.h"
#import "Host_Detail_Ablum_ViewController.h"
#import "SGPageContentCollectionView.h"
#import "SocailViewController.h"
#import "HostablityViewController.h"
@interface HostDetailViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentCollectionView *pageContentCollectionView;
@end

@implementation HostDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigation:1 andTitle:@"主播详情" andNaviColor:[UIColor clearColor] andTitleColor:nil];
    self.icon.layer.cornerRadius = 35;
    self.icon.layer.masksToBounds = 1;
    self.view.backgroundColor = [UIColor whiteColor];
    [self setupPageView];
    [self loadData];
    // Do any additional setup after loading the view from its nib.
}
-(void)loadData{
    NSDictionary *param = @{@"ac":@"member",@"op":@"member",@"ctrl":@"live",@"anchor_id":self.hostid,@"ta":@"anchor_nl"};
    [self weqPostHandle:param success:^(id response) {
        if(response){
            NSDictionary *datas = response[@"data"];
            NSURL *url = [NSURL URLWithString:datas[@"avatar"]];
            [self.icon sd_setImageWithURL:url];
            self.nick_name.text = datas[@"nickname"];
            self.host_Des.text = datas[@"description"];
          
        }
    } failure:^(NSError *error) {
        
    }];
}
- (void)setupPageView {
    CGFloat statusHeight = CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
    CGFloat pageTitleViewY = 0;

    if (statusHeight == 20.0) {
        pageTitleViewY = 64;
    } else {
        pageTitleViewY = 88;
    }
    pageTitleViewY += self.Top_View.frame.size.height;
    
    NSArray *titleArr = @[@"动态", @"历史视频",@"主播能力"];
    SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
    configure.titleColor = [UIColor darkGrayColor];
    configure.titleSelectedColor = [UIColor blackColor];
    configure.titleFont = [UIFont systemFontOfSize:18];
    configure.indicatorColor = BUTTON_COLOR;
    //    configure.indicatorColor = [UIColor blackColor];
    //  configure.indicatorAdditionalWidth = 80; // 说明：指示器额外增加的宽度，不设置，指示器宽度为标题文字宽度；若设置无限大，则指示器宽度为按钮宽度
    configure.titleGradientEffect = YES;
    
    /// pageTitleView
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, pageTitleViewY, screen_width, 44) delegate:self titleNames:titleArr configure:configure];
    [self.view addSubview:_pageTitleView];
    
   // CollectListViewController *oneVC = [[CollectListViewController alloc] init];
        Host_Detail_Ablum_ViewController *twoVC = [[Host_Detail_Ablum_ViewController alloc] init];
    twoVC.hostId = self.hostid;
    SocailViewController *oneVc1 = [[SocailViewController alloc]init];
    HostablityViewController *vc2 = [[HostablityViewController alloc]init];
    vc2.hostId = self.hostid;
    //    ChildVCThree *threeVC = [[ChildVCThree alloc] init];
    //    ChildVCFour *fourVC = [[ChildVCFour alloc] init];
    NSArray *childArr = @[oneVc1, twoVC,vc2];
    /// pageContentCollectionView
    CGFloat ContentCollectionViewHeight = screen_height - CGRectGetMaxY(_pageTitleView.frame);
    self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_pageTitleView.frame), screen_width, ContentCollectionViewHeight) parentVC:self childVCs:childArr];
    _pageContentCollectionView.delegatePageContentCollectionView = self;
    [self.view addSubview:_pageContentCollectionView];
}
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
    [self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
}

- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
